<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>

</head>
<body>
<div id="target" class="div_class"></div>
<button onclick="getFile()">按钮</button>
</body>
<script>
    function getFile() {
        var url="file:///Users/seed/Desktop/1.txt";
        url.indexOf()
        var result;
        //var XMLHttpRequest = require("xmlhttprequest").XMLHttpRequest;
        var xhr=new XMLHttpRequest();
        xhr.open('GET',url,true);
        xhr.send();

        xhr.onreadystatechange=function () {
            if(xhr.readyState==4 && (xhr.status==200  || xhr.status==0)){
                result=xhr.response;
                console.log(result);
            }
        };
    }


</script>

</html>